<template>
  <div id="recorddialog">
    <commonformdialog
      :isshowDialogs="isshowDialog"
      :isshowconfirmbtn="false"
      :dialogWidth="'60%'"
      :enterTitle="false"
      :isshowimportTitle="false"
      :dialogTitle="`成绩记录-${titlename}`"
      @closetextDialog="closetextDialog"
      @confirmbtn='confirmbtn'
    >
	  <div class="innerloding">
		  <el-table :data="tableData" border style="width: 100%">
		    <el-table-column prop="exam_time" label="考试时间" align="center"></el-table-column>
		    <el-table-column prop="subject_type" label="考试科目" align="center"></el-table-column>
		    <el-table-column prop="exam_result" label="考试成绩" align="center"></el-table-column>
		    <el-table-column prop="exam_place" label="考试地点" align="center"></el-table-column>
		    <el-table-column prop="exam_session" label="考试场次" align="center"></el-table-column>
		  </el-table>
		    <el-row>
		      <el-col :span="24" class="pagination">
		        <!-- 翻页 -->
		        <el-pagination
		        class="fr"
		          @size-change="handleSizeChange"
		          @current-change="handleCurrentChange"
		          :current-page="pages.page"
		          :page-sizes="[5]"
		          :page-size="5"
		          background
		          layout="total, sizes, prev, pager, next"
		          :total="pages.total"
		        ></el-pagination>
		      </el-col>
		    </el-row>
	  </div>
     
    </commonformdialog>
  </div>
</template>

<script>
//引入弹窗
import commonformdialog from '@/components/commondialog/commondialog'
import {getachievementlist} from '@/api/student'
export default {
  data() {
    return {
      //标题名字
      titlename: '',
        //表格数据
      tableData: [],
        //页码数据
      pages: {},
      //id
      studentid:'',
      //成绩记录页码
      rpage:1,
      //成绩记录一页多少数据
      rtotal:5,
    }
  },
  components: {
    commonformdialog,
  },
  props: {
    //是否显示弹窗
    isshowDialog: {
      type: Boolean,
      default: false,
    },
    //点击传递的参数
    dialogparams: {
      type: Object,
      default: () => {
        return {}
      }
    },
  },
  methods:{
    //获取成绩记录列表数据
    async getrecordList(){
      let params = {
        page:this.rpage,
        rows:this.rtotal,
        student_id:this.studentid
      }
      let data = await getachievementlist(params)
      if(data.code=='0000'){
        this.tableData = data.data.list
        this.pages = data.data.page
      }
    },
    //一页多少数据翻页
    handleSizeChange(val){
      this.rtotal = val
      this.getrecordList()
    },
    handleCurrentChange(val){
      this.rpage = val
       this.getrecordList()
    },
      //关闭弹窗
    closetextDialog() {
      this.$emit('closetextDialog')
    },
    //点击确认
    confirmbtn(){
      this.$emit('closetextDialog')
    }
  },
  watch: {
    dialogparams(val) {
      this.studentid = val.id
      this.titlename = val.name
    },
    isshowDialog(val){
      if(val){
        this.getrecordList()
      }
    }
  }
}
</script>

<style scoped lang='scss'>
  ::v-deep{
    .el-dialog__body {
      // overflow: hidden;
      height: 320px !important;
      overflow: auto;
    }
  }
</style>
